package com.gopay.common.hessian;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.remoting.caucho.HessianServiceExporter;

import com.caucho.services.server.ServiceContext;

/**
 * 扩展HessianServiceExporter
 * 
 * @GopayHessianServiceExporter.java
 * @author yaobo
 * @2013-7-24 上午10:45:26 www.gopay.com.cn Inc.All rights reserved.
 */
public class GopayHessianServiceExporter extends HessianServiceExporter {
    private static final Logger logger = Logger.getLogger(GopayHessianServiceExporter.class);

    @Override
    public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException,
            IOException {

        try {
            String tokenKey = request.getHeader("Token-Key");
//            logger.error("Token-Key:" + tokenKey);

            ReceiveHessianKey.getInstance(tokenKey);

            // 调用spring自身的实现
            super.handleRequest(request, response);
        } finally {
            ServiceContext.end();
        }
    }
}
